package com.globant.navarrete.fabio.rest.services;

import java.util.Collection;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import org.springframework.stereotype.Service;

import com.globant.navarrete.fabio.rest.dao.IBookDAO;
import com.globant.navarrete.fabio.rest.entities.Book;
import com.globant.navarrete.fabio.utils.SpringApplicationContext;

// MIME for the request
@Consumes({ "application/json" })
// MIME for the response
@Produces({ "application/json" })
@Path("/libraryService")
@Service
public class LibraryService {

  IBookDAO bookDAO;

  @GET
  @Path("/books")
  public Collection<Book> getBooks() {
    this.bookDAO = (IBookDAO) SpringApplicationContext.getBean("bookDAO");
    return this.bookDAO.findAll();
  }
}
